<?php
require_once 'includes/haut.php';
acces($niveau,0);

require_once 'includes/donneesFormulaires.php'; 
require_once 'modules/gestionPanier.php';
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>
			Panier
		</title>
		<?php include('includes/headLinks.php');?>
		<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
		<script type="text/javascript" src="js/triTable.js"></script>
	</head>
	<body>

		<div id="entete">
			<?php include('includes/entete.php'); ?>
		</div>
	
		<div id="navigation">
			<?php include('includes/navigation.php'); ?>
		</div>

		<div id="principal">
			<h2>Mon panier</h2>

			<?php 
			$titres=array('Action', 'Pr&eacute;nom', 'Du</br>Au', 'Activit&eacute;', 'Mat&eacute;riel', 'Niveau', 'Taille', 'Prix');
				
			if (isset($client) && isset($tabReservations)) {
				$total = 0;
				echo('<table class="tabListe">
				<thead><tr>');
					//ecriture des titres de colonnes
					foreach($titres as $x){
						echo'<th>'.$x.'</th>';
					}
				echo('</tr></thead><tbody>');
				
				$count = count($tabReservations);
				for ($x=0;$x<$count;$x++){ 
					$tabResMatCat = $tabReservations[$x];
					$res = $tabResMatCat['reservation'];
					$mat = $tabResMatCat['materiel'];
					$cat = $tabResMatCat['categorie'];
					$activite = getActivite($tabType, $cat->getType());
					$prix = $cat->getPrixTotal($res->getDuree());
					$total +=  $prix;
					
					echo ('<tr>
								<th>
								<a href="formReservation.php?action=modifier&indice='.$x.'">
									<img class="icone" src="images/icones/modifier.png" alt="modifier" title="modifier" />
								</a>
								<a href="formReservation.php?action=supprimer&indice='.$x.'">
									<img class="icone" src="images/icones/error.png" alt="supprimer" title="supprimer" />
								</a>
								</th>
								<td>'.$res->getPrenom().'</td>
								<td>'.$res->getDateDebut().'</br>'.$res->getDateFin().'</td>
					      		<td>'.$activite.'</td>
								<td>'.etiquette($tabType[$activite], $cat->getType()));
								if ($mat->getMarque()!=null) echo ('</br>'.$mat->getMarque());
								if ($mat->getModele()!=null) echo ('</br>'.$mat->getModele());
								echo('</td><td>'.etiquette($tabNiveau[$activite], $cat->getNiveau())
								.'</td>
								<td>'.$mat->getTaille().'</td>
								<td>'.$prix.'&euro;</td>
					      </tr>');
					}
					echo('</tbody></table>')?>
					
					<div class="total">
					Total : <?php echo $total;?>&euro;
					</div>

			
			<form action="panier.php" method="post">
				<p>
					<input type="hidden" name="action" value="valider"/>
					<center>
						<input type="submit" name="reserver" value="Ajouter un autre mat&eacute;riel"/>	
		      			&nbsp;&nbsp;&nbsp;&nbsp;
		      			<input type="submit" name="valider" value="Valider"/>
	      			</center>
				</p>
			</form>
		<?php } else {?>
			<center>Votre panier est vide</br></br>
			<a href="formReservation.php?action=ajouter"><strong>R&Eacute;SERVER !</strong></a>
			</center>
		<?php }?>
			
		</div>
		
		<div id="publicite">
			<?php include('includes/publicite.php'); ?>
		</div>
	</body>
</html>